<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Document</title>
</head>
<body>

    <script>

        var age = prompt("请输入你的出生年：");
        var n = 2022 - age;
        alert("你的年龄是：" + n,"岁"); 

    </script>

</body>
</html>